/*
 * Copyright (C) 2009 M. Hautle.
 * 
 * This file is part of TrackedBean.
 * 
 * TrackedBean is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any later version.
 * 
 * TrackedBean is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License along with TrackedBean. If not, see <http://www.gnu.org/licenses/>.
 */
package ch.trackedbean.tracking.internal;

import ch.trackedbean.tracking.*;

/**
 * Interface for {@link BeanStatusImpl} and {@link StatusList}.
 * 
 * @author M. Hautle
 */
public interface IChildStatus {
    /**
     * Informs this parent about a structure status change in the child.
     * 
     * @param requestId The id of this call, normally a new instance of {@link Object} (used to identify if a call was already processes in a cyclic structure)
     * @param changeDelta The difference in the number of structure changes (of a whole subtree)
     * @param errorDelta The difference in the number of structure errors (of a whole subtree)
     */
    void childStructureStatusChanged(Object requestId, int changeDelta, int errorDelta);

    /**
     * Checks wherever this element is a child or granchild of a given element.
     * 
     * @param requestId The id of this call, normally a new instance of {@link Object} (used to identify if a call was already processes in a cyclic structure)
     * @param element The possible parent element
     * @return True if this element is a child or grandchild of the given element
     */
    boolean isChildOf(Object requestId, IChildStatus element);

    /**
     * Informs this parent that the content of the child, hold in the specified property, has changed.<br>
     * This method
     * 
     * @param property The concerned property or null if not hold by a property
     * @param child The child
     */
    void childContentChanged(String property, Object child);

    /**
     * Returns the element status.
     * 
     * @return The element status
     */
    BeanStatusFlag getStatusFlag();

    /**
     * Returns the structure status.
     * 
     * @return The structure status
     */
    BeanStatusFlag getStructureStatusFlag();

    /**
     * Returns the number of children containing changes in their structure ({@link BeanStatusFlag#CHANGED} flag)<br>
     * You may look at this value as the numerical representation of the change part in {@link #getStructureStatusFlag()}.<br>
     * The status property of this bean is handled like the status of a child.
     * 
     * @return The structure change count
     */
    int getStructureChangeCount();

    /**
     * Returns the number of children containing errors in their structure ({@link BeanStatusFlag#ERROR} flag)<br>
     * You may look at this value as the numerical representation of the error part in {@link #getStructureStatusFlag()}.<br>
     * The status property of this bean is handled like the status of a child.
     * 
     * @return The structure error count
     */
    int getStructureErrorCount();
}
